/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;

import entidades.Docente;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Administrador
 */
@Stateless
public class DocenteFacade extends AbstractFacade<Docente> {
    @PersistenceContext(unitName = "SistemasDistribuidos-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public DocenteFacade() {
        super(Docente.class);
    }
    
    public boolean getDocentebyLegajo(Docente docente, Long legajo){
        
        boolean retorno = false;
        try{
            Query query = em.createQuery("SELECT d FROM Docente d WHERE d.legajo = :legajo ");
            query.setParameter("legajo", legajo);
            docente = (Docente) query.getSingleResult();
            retorno = true;
        } catch (NoResultException nre) {
            nre.printStackTrace();
        } finally {
            return retorno;
        }
        
    }
    
}
